package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectInputStreamDemo1 {
    public static void main(String[] args) throws IOException {
        //1.构建对象输入流对象
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream(".\\obj.data"));
        //2.读取文件数据(读的顺序一定要和写的顺序一致）
        int n=ois.readInt();    //读writeInt写入的数据
        boolean b=ois.readBoolean();    //读writeBoolean写入的数据
        String s1=ois.readUTF();    //读writeUTF写入的数据
        String s2=ois.readUTF();    //读writeUTF写入的数据
        System.out.println("读到的数据为："+n+"/"+b+"/"+s1+"/"+s2);
        //3.释放资源
        ois.close();
    }
}
